package com.koron.css2.baseConfig.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.baseConfig.mapper.WaterTypeMapper;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.SelectBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.util.Constant;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

import java.util.List;

public class WaterTypeTopList implements ServerInterface{
	private Logger log = LogManager.getLogger(WaterTypeTopList.class);
	
	@Override
	public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
		 @SuppressWarnings("rawtypes")
	        MessageBean<List> info = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "success", List.class);
	        try {
	        	WaterTypeMapper mapper = factory.getMapper(WaterTypeMapper.class);
	        	List<SelectBean> list = mapper.findTopWaterType();
	        	info.setData(list);
	        }catch (Exception e) {
	            info.setCode(Constant.MESSAGE_DBFAIL);
	            info.setDescription("操作异常");
	            logger.error("操作异常", e);
	            factory.close(false);
	        }
	        return info;
	}

}
